package server.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("资源控制表")
public class FrmDataResources {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "server.tool.idProduce.NumberIdProduce")
    private String id;

    @Column
    private String name;

    @Column
    private String uri;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Type {
        VIEW("页面"),
        API("接口");

        Type(String display) {
            this.display = display;
        }

        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }

    @Enumerated(EnumType.STRING)
    @Column
    @ApiModelProperty("资源类型")
    private Type type;

    @Column
    private Boolean status;

    @Column
    private String rule;
}
